//
//  WCheckgoodsBbottowV.m
//  ProjectforHDX
//
//  Created by motom on 16/8/24.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "WCheckgoodsBbottomV.h"

@interface WCheckgoodsBbottomV()

@property (nonatomic, strong) RZCustomButtom *finishBtn;

/*
 *扫描二维码按钮
 */
@property (nonatomic, strong) RZCustomButtom *scanQRCodeBtn;

/*
 *扫描一维码按钮
 */
@property (nonatomic, strong) RZCustomButtom *scanBarcodeBtn;


/*
 *扫描库位按钮
 */
@property (nonatomic, strong) RZCustomButtom *scanLocationBtn;



@end

@implementation WCheckgoodsBbottomV


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupView];
    }
    return  self;
}


-(void)setupView
{
    CGFloat btnWith = (SCREEN_WIDTH - 10 * 5)/4;
    self.finishBtn = [self createBtn:0 withSize:CGSizeMake(btnWith, 35)];
    self.scanQRCodeBtn = [self createBtn:1 withSize:CGSizeMake(btnWith, 35)];
    self.scanBarcodeBtn = [self createBtn:2 withSize:CGSizeMake(btnWith, 35)];
    self.scanLocationBtn = [self createBtn:3 withSize:CGSizeMake(btnWith, 35)];
}

- (void)setIsCunOrquJian:(BOOL)isCunOrquJian{
    _isCunOrquJian = isCunOrquJian;
    // 如果是存取件重设完成按钮
    CGFloat btnWith = (SCREEN_WIDTH - 10 * 5)/4;
    [self.finishBtn removeFromSuperview];
    [self.scanLocationBtn removeFromSuperview];
    if (isCunOrquJian!=NO) {
        self.scanLocationBtn = [self createBtn:6 withSize:CGSizeMake(btnWith, 35)];
    }
    self.finishBtn = [self createBtn:5 withSize:CGSizeMake(btnWith, 35)];
}

-(RZCustomButtom *)createBtn:(NSInteger)tag withSize:(CGSize)size
{
    RZCustomButtom *btn = [[RZCustomButtom alloc]init];
    [self addSubview:btn];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:[UtilCheck language:[NSString stringWithFormat:@"delivery.bottom%ld",(long)tag]] forState:UIControlStateNormal];
    btn.titleLabel.numberOfLines = 0;
    btn.tag = tag;
    [btn setFrame:CGRectMake(0, 0, size.width, size.height)];
    [btn addRadius:3 borderwidth:1 bordercolor:[UtilCheck hexStringToColor:@"f0f0f0" alpha:1]];
    if (tag == 0 || tag == 5) {
        [btn setBackgroundColor:SYSTEM_COLOR];
        [btn setTitleColor:[UIColor whiteColor]  forState:UIControlStateNormal ];
    }
    else
    {
        [btn setTitleColor:[UIColor blackColor]  forState:UIControlStateNormal ];

    }
    [btn.titleLabel setFont:CustomFont(14)];
    
    return btn;
}


-(void)layoutSubviews
{
    self.finishBtn.right = SCREEN_WIDTH -10;
    self.finishBtn.top = 10;
    
    self.scanQRCodeBtn.right = self.finishBtn.left-10;
    self.scanQRCodeBtn.top = 10;
    
    self.scanBarcodeBtn.right = self.scanQRCodeBtn.left -10;
    self.scanBarcodeBtn.top = 10;
    
    self.scanLocationBtn.right = self.scanBarcodeBtn.left - 10;
    self.scanLocationBtn.top = 10;
    
    [self addSoldLine:1.0 soldcolor:[UtilCheck hexStringToColor:@"f0f0f0" alpha:1.0] pointA:CGPointMake(0, 0) pointB:CGPointMake(SCREEN_WIDTH, 0)];

}

-(void)btnClick:(RZCustomButtom *)btn
{
    self.Bottomblock(btn.tag);
}


@end
